package gamer2;


import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLProfile;
import javax.media.opengl.awt.GLJPanel;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;

import com.jogamp.opengl.util.Animator;
import com.jogamp.opengl.util.FPSAnimator;


public class OGLCanvas extends JPanel  {

	
	static private GLJPanel glcanvas;
	
	
	OGLCanvas() {
		// renderer.canvas = glcanvas;
		//glcanvas.addGLEventListener(renderer);
		GLProfile profile = GLProfile.get(GLProfile.GL2);
		GLCapabilities capabilities = new GLCapabilities(profile);
		glcanvas = new GLJPanel(capabilities);
		glcanvas.setPreferredSize(new Dimension(600,600));
		final Renderer renderer = new Renderer();
		add(glcanvas);
		glcanvas.addGLEventListener(renderer);

		JButton btnRenderer = new JButton("Render");
		btnRenderer.addActionListener(new ActionListener() {
			
			public void actionPerformed(ActionEvent arg0) {
				// TODO Auto-generated method stub
				///System.exit(1);
				glcanvas.repaint();
			}
		});
		
		add(btnRenderer);
		
/*		FPSAnimator animator = new FPSAnimator(glcanvas, 1);
		animator.add(glcanvas);
		animator.start();
	*/	
/*		glcanvas.addKeyListener(renderer);
		glcanvas.addMouseListener(renderer);
		glcanvas.addMouseMotionListener(renderer);
*/
		
	}


}
